import React, { Component } from 'react';

import { Redirect, Route, Switch } from 'react-router-dom';

import Home from './Index/Home';
import Fenlei from '../views/Index/Fenlei';
import Shop_Cart from '../views/Index/Shop_Cart';
import My from '../views/Index/My';
import NotFound from '../views/NotFound';


import MyTabbar from '../components/MyTabbar'

class Index extends Component {

    render() {
        return (
            <div className='index'>
                {/*this.props.children用来保存父组件在渲染子组件是通过子组件内容区传入的数据/组件*/}
                {/* {this.props.children} */}
                {/* Switch默认匹配当前项，刷新不会重定向 */}
                <Switch>
                    <Route path="/index/home" component={Home} />
                    <Route path="/index/fenlei" component={Fenlei} />
                    <Route path="/index/shop_cart" component={Shop_Cart} />
                    <Route path="/index/my" component={My} />

                    {/* 路由重定向 exact精准匹配 */}
                    <Redirect from='/index' to="/index/home" exact />

                    {/* 404 */}
                    <Route path="*" component={NotFound} />
                </Switch>
                <MyTabbar />
            </div>
        );
    }
}

export default Index;